package com.beilang.hotline.dept.manager.impl;

import java.util.List;
import java.util.ArrayList;

import com.beilang.base.pagination.PaginationHelper;
import com.beilang.hotline.dept.dao.DeptDAO;
import com.beilang.hotline.dept.manager.DeptMgr;
import com.beilang.hotline.dept.model.DeptModel;
import com.beilang.hotline.dept.to.SearchTO;

public class DeptMgrImpl implements DeptMgr{
	private DeptDAO deptDAO;

    public void setDeptDAO(DeptDAO deptDAO) {
		this.deptDAO = deptDAO;
	}

	public DeptModel createDept(DeptModel deptModel){
		return deptDAO.createDept(deptModel);
	}

	public DeptModel saveDept(DeptModel deptModel){
		return deptDAO.saveDept(deptModel);
	}

	public void deleteDept(Long deptId){
		deptDAO.deleteDept(deptId);
    }

	public DeptModel getDept(Long deptId){
		return deptDAO.getDept(deptId);

	}

	public PaginationHelper getDeptList(PaginationHelper helper, SearchTO searchTO){
		int count = deptDAO.searchCount(searchTO);
		helper.setTotalSize(count);
		List list = deptDAO.searchList(helper, searchTO);
		helper.setList(list);
		return helper;
	}

	public List getAllDept(){
		List list= deptDAO.getAll(DeptModel.class);
        if(list!=null&&list.size()>0){
            List l=new ArrayList();
            for(int i=0;i<list.size();i++){
                DeptModel d=(DeptModel)list.get(i);
                if(d.getDeleteInd().equalsIgnoreCase("N")){
                    l.add(d);
                }
            }
            return l;
        }
        return list;
    }

}
